<template>
    <div>
        学员查询
        <el-button type="primary" v-perm:study:student:insert="insert">添加</el-button>
        
        <el-table :data="students" border stripe>
            <el-table-column type="index" width="50" />
            <el-table-column label="编号" prop="studentno">
            </el-table-column>
            <el-table-column label="姓名" prop="studentname">
            </el-table-column>
            <el-table-column label="操作">
                <template #default="scope">
                    <el-button :row="scope.row" type="primary" v-perm:study:student:update="update" >修改</el-button>
                </template>
            </el-table-column>
            
        </el-table>
        

        <el-dialog
            :title="title"
            v-model="visible">
            <router-view :data="data" @close="close"></router-view>
        </el-dialog>
        
    </div>
</template>

<script setup>
import {ref} from 'vue'
import router from '@/router'
import reqeust from '@/api/request'
let visible = ref(false)
let title = ref("")
let students = ref([])
let data = ref({})

let loadData = ()=>{
    reqeust.get("/study/student/find").then(resp=>{
        students.value = resp.data
    })
}
loadData();
let insert = (menu)=>{
    title.value = menu.cname
    visible.value = true;
    console.log(menu)
    router.push(menu.path)
}

let update = (menu,row)=>{
    title.value = menu.cname
    visible.value = true;
    data.value = row
    router.push(menu.path)
}
let close = ()=>{
    visible.value = false;
}
</script>

<style lang='scss' scoped>

</style>
